from usr.window import Window
from usr.theme import Theme
import gc
import uos

class AboutWindow(Window):
    def on_draw(self):
        self.draw_background()
        #self.draw_frame()
        version = '  QPY Test\n   v1.0.2'
        self.draw_text(24, 24, 216, 216, version, Theme.THEME_FOREGROUND, Theme.THEME_BACKGROUND)
        del version
        self.update_mem()
    

    def update_mem(self):
        free_mem = gc.mem_free()
        #used_mem = gc.mem_alloc()
        stats = uos.statvfs('usr')
        disk = stats[0] * stats[3]
        mem_info = '内存:{0:.0f}K\n存储:{1:.0f}K'.format(free_mem/1024, disk / 1024)
        #print(mem_info)
        self.draw_text(16, 152, 223, 223, mem_info, Theme.THEME_FOREGROUND, Theme.THEME_BACKGROUND)
        del mem_info
